#pragma once

#include <QtNetwork>
#include <QObject>
#include <QString>
#include <QTextStream>

#include <QTcpServer>
#include <QTcpSocket>
#include <QList>
#include <QString>
#include <QTimer>

#include "webpage.h"
#include "httpClient.h"

struct parsedQuery
{
    QString vpath;
    QString useragent;
    QString referer;
    QString cookie;    
};

class Server : public QObject
{
    Q_OBJECT

    public:
        Server(QObject *parent = 0);
        ~Server();

        http_client *LookFor(QTcpSocket *socket);
        
    public slots:
        void acceptConnection();
        void startRead();
        void clientDisconnected();
        void dnc();

        void responseMgr(http_client *client);

    private:
		QString header(unsigned int status, unsigned int lenght);
        parsedQuery *parseQuery(QString header);
        QTcpServer server;

        webpage *page;
        FileList *fl;
        QList<http_client*> clients;
};
